package com.ruoyi.group.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.group.domain.RpCommunication;
import com.ruoyi.group.domain.dto.DeptOrderDto;
import com.ruoyi.group.domain.dto.OrderDetailsDto;
import com.ruoyi.group.service.OrderDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author:黄志超
 * @Todo:返回工单详情
 * @DateTime:2022/3/16 16:48
 * @Component:蜗牛
 **/
@RestController
@RequestMapping("/detailsOrder")
public class OrderDetailsController extends BaseController {

    @Resource
    private OrderDetailsService orderDetailsService;

    @PostMapping("/find/{orderNo}")
    public AjaxResult doSome(@PathVariable String orderNo){
        Integer userid = getUserId().intValue();
        DeptOrderDto all = orderDetailsService.findAll(orderNo, userid);
        if (all!=null){
           return AjaxResult.success(all);
        }
        return AjaxResult.error();
    }

    @PostMapping("/sub")
    public AjaxResult doSome1(@RequestBody RpCommunication rpCommunication){
        if(orderDetailsService.subCommunication(rpCommunication)){
            return AjaxResult.success();
        }
        return AjaxResult.error();
    }

    @PostMapping("/findOne/{orderNo}")
    public TableDataInfo tableDataInfo(@PathVariable String orderNo){
        startPage();
        List<RpCommunication> list = orderDetailsService.findKeeperOrder(orderNo);
        return getDataTable(list);
    }

}
